KcUpdate Subroutine

private subroutine KcUpdate(time)

read new Kc values

Arguments

Type IntentOptional Attributes Name
type(DateTime), intent(in) :: time

Variables

Type Visibility Attributes Name Initial
integer(kind=short), public :: i
integer(kind=short), public :: j
integer(kind=short), public :: k

Source Code

SUBROUTINE KcUpdate &
!
( time )

IMPLICIT NONE

!Arguments with intent(in):
TYPE (DateTime), INTENT(IN) :: time

!local declarations:
INTEGER (KIND = short)   :: i, j, k

!------------------------------end of declarations-----------------------------

SELECT CASE (interpolationMethodKc)
    
   CASE (0) !update map from netcdf
       CALL ReadField (filenameKc, time, dtKc, dtKc, 'M', kc_map)
    
   CASE (1) !update kc map from map of crop coefficient code 
       !read new data
       CALL ReadData (network = kc_stations, fileunit = fileunitKc, &
                      time = time, aggr_time = dtKc, &
                      aggr_type = 'ave')
	
	    !interpolation
	    DO i = 1, kc_map % idim
	      DO j = 1, kc_map % jdim
		      IF ( kc_map % mat(i,j) == kc_map % nodata ) CYCLE
			
                DO k = 1, kc_stations % countObs
			        IF ( ToString ( kc_code_map % mat(i,j) ) == &
                          kc_stations % obs(k) % id ) THEN
                        
				       kc_map % mat(i,j) = kc_stations % obs(k) % value
                       EXIT
                       
				    END IF
			    END DO
          END DO
	    END DO
END SELECT

RETURN

END SUBROUTINE KcUpdate